<template>
  <div class="cart-item">
    <div class="cart-selector">
      <check-button :is-checkd="product.checkd" @click.native="checkClick"></check-button>
    </div>
    <div class="cart-img">
      <img :src="product.image" alt="">
    </div>
    <div class="cart-detail">
      <div class="cart-title">{{product.title}}</div>
      <div class="cart-desc">{{product.desc}}</div>
      <div class="cart-num">
        <span class="price">￥{{product.price}}</span>
        <span class="count">X{{product.count}}</span>
      </div>
    </div>

  </div>
</template>

<script>

  import CheckButton from "../../../components/content/checkButton/CheckButton";

  export default {
    name: "CartListItem",
    props: {
      product: {
        type: Object,
        default() {
          return {}
        }
      }
    },
    methods: {
      checkClick() {
        this.product.checkd = !this.product.checkd
      }
    },
    components: {
      CheckButton
    }
  }
</script>

<style scoped>

  .cart-item {
    width: 100%;
    padding: 5px;
    border-bottom: 1px solid #ccc;
    display: flex;
  }

  .cart-selector {
    width: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 5px;
  }


  .cart-img {
    margin-right: 10px;
  }

  .cart-img img {
    width: 80px;
    height: 100px;
    border-radius: 5px;

  }

  .cart-detail {
    position: relative;
    overflow: hidden;
    font-size: 17px;
  }

  .cart-title, .cart-desc {
    white-space: nowrap; /*文字显示不开,强制一行*/
    overflow: hidden; /*溢出的部分隐藏*/
    text-overflow: ellipsis; /*文字用省略号代替*/
  }

  .cart-title {
    margin-bottom: 15px;
    color: black;
  }

  .cart-desc {
    font-size: 14px;
  }

  .cart-num {
    display: flex;
    justify-content: space-between;
    margin-top: 25px;
  }

  .cart-num .price {
    color: orange;
  }
</style>
